<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<meta charset="utf-8">
<head>
	<link rel="shortcut icon" href="favicon.ico">
	<link th:href="@{/css/bootstrap.min.css}" rel="stylesheet"/>
	<link th:href="@{/css/layui.css}" rel="stylesheet" >
	<link th:href="@{/css/font-awesome.css}" rel="stylesheet"/>
	<!-- bootstrap-table 表格插件样式 -->
	<link th:href="@{/ajax/libs/bootstrap-table/bootstrap-table.min.css}" rel="stylesheet"/>
	<link th:href="@{/ajax/libs/jqTreeGrid/jquery.treegrid.css}" rel="stylesheet"/>
	<link th:href="@{/css/animate.css}" rel="stylesheet"/>
	<link th:href="@{/css/style.css}" rel="stylesheet"/>
	<link th:href="@{/css/checkbox.css}" rel="stylesheet"/>
	<link th:href="@{/ajax/libs/select/select2.css}" rel="stylesheet"/>
	<link th:href="@{/ruoyi/css/ry-ui.min.css}" rel="stylesheet"/>
	<link href="/ajax/libs/iCheck/custom.css" th:href="@{/ajax/libs/iCheck/custom.css}" rel="stylesheet"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
	<form class="form-horizontal m" id="form-user-add">
		<input name="userId"  type="hidden"  />
		<input name="deptId"  type="hidden"  id="treeId" />
		<div class="form-group">
			<label class="col-sm-3 control-label">部门名称：</label>
			<div class="col-sm-8">
				<input class="form-control" type="text"  name="deptName" onclick="selectDeptTree()" readonly="true" id="treeName" >
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">姓名：</label>
			<div class="col-sm-8">
				<input class="form-control" type="text" name="realName" id="realName" >
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">性别：</label>
			<div class="col-sm-8">
				<select id="sex" class="form-control m-b">
					<option >男</option>
					<option >女</option>
				</select>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label ">职工邮箱：</label>
			<div class="col-sm-8">
				<input class="form-control" type="text" name="email" id="email" />
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">籍贯：</label>
			<div class="col-sm-8">
				<input class="form-control" type="text" name="address" id="address" >
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">状态：</label>
			<div class="col-sm-8">
				<select id="status" class="form-control m-b" name="id">
					<option >在职</option>
					<option >离职</option>
				</select>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">岗位：</label>
			<div class="col-sm-8">
				<select id="parentRole" name="parentRole" class="form-control select2">
					<option th:each="roleitem:${roleList}" th:value="${roleitem.roleId}" th:text="${roleitem.roleDescription}"></option>
				</select>
			</div>
		</div>
		<div class="form-group">
			<div class="form-control-static col-sm-offset-9">
				<button type="button" onclick="add()" class="btn btn-primary">提交</button>
				<button onclick="$.modal.close()" class="btn btn-danger" type="button">关闭</button>
			</div>
		</div>
	</form>
</div>
<script th:src="@{/js/jquery.min.js}"></script>
<script th:src="@{/js/bootstrap.min.js}"></script>
<!-- bootstrap-table 表格插件 -->
<script th:src="@{/ajax/libs/bootstrap-table/bootstrap-table.min.js}"></script>
<script th:src="@{/ajax/libs/bootstrap-table/locale/bootstrap-table-zh-CN.min.js}"></script>
<script th:src="@{/ajax/libs/bootstrap-table/extensions/mobile/bootstrap-table-mobile.min.js}"></script>
<script th:src="@{/ajax/libs/bootstrap-table/extensions/toolbar/bootstrap-table-toolbar.min.js}"></script>
<!-- Data Tables -->
<script th:src="@{/js/plugins/dataTables/jquery.dataTables.js}"></script>
<script th:src="@{/js/plugins/dataTables/dataTables.bootstrap.js}"></script>
<script th:src="@{/js/plugins/jeditable/jquery.jeditable.js}"></script>
<script th:src="@{/js/plugins/layer/laydate/laydate.js}"></script>
<script th:src="@{/ajax/libs/jquery-layout/jquery.layout-latest.js}"></script>
<script th:src="@{/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.all-3.5.js}"></script>
<script th:src="@{/ajax/libs/layer/layer.min.js}"></script>
<script th:src="@{/ajax/libs/layui/layui.js}"></script>
<script th:src="@{/ruoyi/js/common.js?v=2.2.0}"></script>
<script th:src="@{/ruoyi/js/yuyu-ui.min.js?v=2.2.0}"></script>
<script th:src="@{/ajax/libs/iCheck/icheck.min.js}"></script>
<script th:src="@{/ajax/libs/select/select2.js}"></script>
<script>
    function add() {
        var deptId = $("input[name='deptId']").val();
        var email = $("input[name='email']").val();
        var realName = $("input[name='realName']").val();
        var address = $("input[name='address']").val();
        var sex = $("#sex option:selected").val();
        var status =  $("#status option:selected").val() == "在职" ? 1 : 2;
        var roleId =  $("#parentRole option:selected").val();
        var json = {
            "deptId" : deptId,
            "email" : email,
            "realName": realName,
            "address" : address,
            "sex": sex,
            "status" : status
        };
        $.ajax({
            cache : true,
            type : "post",
            url : "/user/adduser/"+roleId,
            data: JSON.stringify(json),
            dataType:'json',
            contentType:"application/json",
            async : false,
            error : function(request) {
                $.modal.alertError("系统错误");
            },
            success : function(data) {
                if (data.code==200){
                    parent.layer.msg('添加成功', {icon: 1});
                    setTimeout(function () {
                        parent.refreshTable();
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    },500);
                }
            }
        });
    }
    /*用户管理-修改-选择部门树*/
    function selectDeptTree() {
        var treeId = $("#treeId").val();
        var deptId = treeId == null || treeId == "" ? "100" : treeId;
        var url = "/system/dept/selectDeptTree/" ;
        $.modal.open("选择部门", url, '380', '380');
    }
</script>
</body>
</html>
